-
Notifications
You must be signed in to change notification settings - Fork 3.2k
perf: use requiresAttentionFromCurrentUser from a derived value #61586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: use requiresAttentionFromCurrentUser from a derived value #61586
Conversation
…ntionFromCurrentUser-from-derived-value
There is still one |
To avoid chaos, I'll undraft this one when we get #61376 merged, since they both share a bit of changes |
…tentionFromCurrentUser-from-derived-value
@@ -73,13 +73,13 @@ export default createOnyxDerivedValueConfig({ | |||
dataToIterate = prepareReportKeys(updates); | |||
recentlyUpdated = updates; | |||
} else if (!!transactionsUpdates || !!transactionViolationsUpdates) { | |||
let transactionReportIds: string[] = []; | |||
let transactionReportIDs: string[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressing this NAB comment from previous PR #61376 (comment) here cc @mountiny
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@allroundexperts can you please prioritize this one? thanks! |
…tentionFromCurrentUser-from-derived-value
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppUnable to build android Android: mWeb ChromeScreen.Recording.2025-05-15.at.4.16.02.AM.moviOS: HybridAppScreen.Recording.2025-05-15.at.4.13.15.AM.moviOS: mWeb SafariScreen.Recording.2025-05-15.at.4.11.07.AM.movMacOS: Chrome / SafariScreen.Recording.2025-05-15.at.4.06.13.AM.movMacOS: DesktopScreen.Recording.2025-05-15.at.4.19.02.AM.mov |
@TMisiukiewicz The report with task assigned doesn't always go up the pinned report. Screen.Recording.2025-05-15.at.4.08.26.AM.movScreen.Recording.2025-05-15.at.4.15.02.AM.mov |
@TMisiukiewicz is OOO, checking with the team if not I can take a look at this. |
@allroundexperts can you check if this is not the case in |
I can reproduce there, but the test steps state that "Verify the report with GBR goes above the pinned report". I guess those were not correct 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't want to block the improvement on this, but @TMisiukiewicz @kacper-mikolajczak @OlimpiaZurek could you take a look and make sure we do not use this getter pattern and always use the attributes from the onyx in component?
let reportAttributes: ReportAttributesDerivedValue['reports']; | ||
let reportAttributesDerivedValue: ReportAttributesDerivedValue['reports']; | ||
Onyx.connect({ | ||
key: ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, | ||
callback: (value) => { | ||
if (!value) { | ||
return; | ||
} | ||
reportAttributes = value.reports; | ||
reportAttributesDerivedValue = value.reports; | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is an antipattern now and we should always subscribe to the attributes in the component using useOnyx and pass them to the utils method - this should ensure the component is always re-rendered when the attribute changes and that the utils method remains pure.
@TMisiukiewicz @kacper-mikolajczak what do you think? Could you look into this to refactor its usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it should be passed to the util methods from useOnyx
. The only caveat is that in some cases, those values might be used deep within the function logic, not just as top-level arguments. Refactoring might result in passing them through multiple layers of intermediate calls.
I'll verify if it'll introduce the additional complexity
function getReportAttributes(reportID: string | undefined, reportAttributes?: ReportAttributesDerivedValue['reports']) { | ||
const attributes = reportAttributes ?? reportAttributesDerivedValue; | ||
|
||
if (!reportID || !attributes?.[reportID]) { | ||
return; | ||
} | ||
return attributes[reportID]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we dont want to create these getters in general and always use the attributes fetched from onyx in the component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed this comment here: #62464
Hi @mountiny 👋 @TMisiukiewicz is currently OOO - quickly looking at it now and it is a nice structural improvement, I am going to look into it more carefully tomorrow 👍 🔜 |
Hey I'm back 👋 I'll create a follow up PR today |
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.48-0 🚀
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.48-0 🚀
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.49-5 🚀
|
We've got an intermittent issue. Team was not able to consistently repro. Report with GBR goes under the pinned report for expense reports. However issue is not repro for direct message reports video_63.mp4 |
@kacper-mikolajczak @TMisiukiewicz can you take a look please? |
🚀 Deployed to production by https://github.com/arosiclair in version: 9.1.50-0 🚀
|
Explanation of Change
requiresAttentionFromCurrentUser
is already calculated in thereportAttributes
so we can replace the function calls in the app with reading it straight from a derived value.Function:
requiresAttentionFromCurrentUser
Action: Create new chat
Before: 123ms
After: 11ms
Fixed Issues
$ #59350
$ #59825
PROPOSAL:
Tests
Offline tests
n/a
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-web.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov